<?php
class HackerU_Db_Conn
{
	const HOST = 'localhost';
	const USER_NAME = 'root';
	const PASSWORD = '3910';
	const DB_NAME = 'hackeru';
	
	private static $instance = null;
	private $conn;
	
	
	public static function getInstance()
	{
		if(self::$instance === null){
			self::$instance = new self();
		}
		return self::$instance;
	}
	
	private function __construct()
	{
		try{
			$this->conn = new mysqli(
							self::HOST,
							self::USER_NAME,
							self::PASSWORD,
							self::DB_NAME 
						);
			if ($this->conn->connect_error) {
			    die('Connect Error (' . $this->conn->connect_errno . ') ' . $this->conn->connect_error);
			}
		}catch(PDOException $e){
			var_dump($e->getMessage());
		}
	}
	
	public function getConn()
	{
		return $this->conn;
	}
	
	public function __destruct()
	{
		$this->conn->close();
		unset($this);
	}
}